﻿//StatisticParameterPanel.xaml.cs
//Copyright (c) 2013 StockSharp LLC, all rights reserved.
//This code module is part of StockSharp library.
//This code is licensed under the GNU GENERAL PUBLIC LICENSE Version 3.
//See the file License.txt for the license details.
//More info on: http://stocksharp.com

namespace StockSharp.Xaml
{
	using System.Collections.Generic;
	using System.Collections.ObjectModel;

	using Ecng.Collections;

	using StockSharp.Algo.Statistics;
	using StockSharp.Algo.Strategies;

	/// <summary>
	/// Визуальная панель для отображения параметров <see cref="IStatisticParameter"/>.
	/// </summary>
	public partial class StatisticParameterPanel
	{
		/// <summary>
		/// Создать <see cref="StatisticParameterPanel"/>.
		/// </summary>
		public StatisticParameterPanel()
		{
			InitializeComponent();
			Parameters = new ObservableCollection<IStatisticParameter>();
			Panel.ItemsSource = Parameters;
		}

		/// <summary>
		/// Форсировать отрисовку параметров.
		/// </summary>
		public void Refresh()
		{
			Panel.Items.Refresh();
		}

		/// <summary>
		/// Параметры, которые необходимо отображать.
		/// </summary>
		public IList<IStatisticParameter> Parameters { get; private set; }

		private Strategy _strategy;

		/// <summary>
		/// Стратегия, статистические параметры <see cref="Algo.Strategies.Strategy.StatisticManager"/> которой необходимо отображать.
		/// </summary>
		public Strategy Strategy
		{
			get { return _strategy; }
			set
			{
				if (value == Strategy)
					return;

				Parameters.Clear();
				_strategy = value;

				if (_strategy != null)
					Parameters.AddRange(_strategy.StatisticManager.Parameters);
			}
		}
	}
}
